﻿using Microsoft.AspNetCore.Mvc;
using System.IO;
namespace MQTT.Broker.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class MqttController : ControllerBase
    {
        [HttpPost]
        [HttpOptions]
        public void Publish(string topic)
        {
            
                MemoryStream ms = new MemoryStream();
                Request.BodyReader.AsStream().CopyTo(ms);
                ms.Position = 0;
                MqttHelper.PublishAsync(topic, ms.ToArray());
            
        }
    }
}
